package leetCode;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class t202 {
    public static void main(String[] args) {
        new Solutiont202().isHappy(19);
    }
}
class Solutiont202 {
    public boolean isHappy(int n) {
        Set<Integer>set=new HashSet<>();
        while (n!=1){
            if (set.contains(n)){
                return false;
            }
            set.add(n);
            n = returnRet(n);
        }
        return true;
    }
    public int returnRet(int n){
        int ret=0;
        while (n!=0){
            ret+=(n%10)*(n%10);
            n=n/10;
        }
        return ret;
    }
}

